//活动管理模块的接口
import request from '@/utils/request'
import type {
  Activity,
  Records,
  Status,
//枚举地址
} from './type'
import { RoleResponseData } from '@/api/acl/role/type'

enum API {
  //获取所有活动
  ALLACTIVITY_URL = '/activity/getSeckillActivityAll',
  //获取活动根据状态
  LISTACTIVITY_URL = '/activity/getSeckillActivityList',
  //添加一个新活动
  ADDACTIVITY_URL = '/activity/saveSeckillActivity',
  //获取活动详情
  GETACTIVITYBYID_URL = '/activity/getSeckillActivityById',
  //修改状态
  UPDATESTATUS_URL = '/activity/updateStatus',
  //删除活动
  DELACTIVITY_URL = '/activity/delActivity',
  //根据时间和状态获取活动列表
  GETSECKILLACTIVITYLISTBETWEENSTARTTIMEANDENDTIME_URL = '/activity/getSeckillActivityListBetweenStartTimeAndEndTime',
}

//获取所有活动
export const reqActivityInfoAll = () => {
  return request.post<any, any>(API.ALLACTIVITY_URL)
}
//根据状态获取活动
export const reqActivityInfoList = (status: string) =>
  request.get<any, any>(
    API.LISTACTIVITY_URL + `/?status=${status}`,
  )
//删除活动
export const reqDelActivity = (id: number) =>
  request.get<any, any>(
    API.DELACTIVITY_URL + `/?id=${id}`,
  )
//获取活动详情
export const reqGetActivityById = (id: number) =>
  request.get<any, any>(
    API.GETACTIVITYBYID_URL + `/?id=${id}`,
  )
// 增加活动
export const reqAddActivity = (data: Records) => {
  return request.post<any, any>(API.ADDACTIVITY_URL, data)
}
// 修改活动状态
export const reqUpdateStatus = (id: number, status: string) =>
  request.get<any, any>(
    API.UPDATESTATUS_URL + `/?status=${status}&id=${id}`,
  )
// 根据时间和状态获取活动列表
export const reqGetSeckillActivityListBetweenStartTimeAndEndTime = (currentTime: string, status: string) =>
  request.get<any, any>(
    API.GETSECKILLACTIVITYLISTBETWEENSTARTTIMEANDENDTIME_URL + `/?currentTime=${currentTime}&status=${status}`,
  )
